#!/bin/bash

#php优化
PP3=`cat -n /usr/local/php/etc/php.ini  | grep cgi.fix_pathinfo=   | awk '{print $1}'`
sed -i ''"$PP3"'c cgi.fix_pathinfo=1'  /usr/local/php/etc/php.ini
PP4=`cat -n /usr/local/php/etc/php.ini  | grep open_basedir   | grep "="  | awk '{print $1}'`
sed -i ''"$PP4"'c ;open_basedir = .:/tmp/:'  /usr/local/php/etc/php.ini
PP5=`cat -n /usr/local/php/etc/php.ini  | grep input_vars | awk '{print $1}'`
sed -i ''"$PP5"'c  max_input_vars = 10000'  /usr/local/php/etc/php.ini
PP6=`cat -n /usr/local/php/etc/php.ini  | grep execution   | grep "="  | awk '{print $1}'`
sed -i ''"$PP6"'c  max_execution_time = 600'  /usr/local/php/etc/php.ini
PP7=`cat -n /usr/local/php/etc/php.ini  | grep max_input_time   | grep "="  | awk '{print $1}'`
sed -i ''"$PP7"'c  max_input_time = 600'  /usr/local/php/etc/php.ini
PP8=`cat -n /usr/local/php/etc/php.ini  | grep display_errors   | grep "="  | awk '{print $1}'`
sed -i ''"$PP8"'c display_errors = Off'  /usr/local/php/etc/php.ini

AA=`cat -n  /usr/local/php/etc/php-fpm.conf  | grep max_children  | awk '{print $1}'`
sed -i ''"$AA"'c  pm.max_children = 30 '    /usr/local/php/etc/php-fpm.conf
BB=`cat -vn /usr/local/php/etc/php-fpm.conf | grep max_spare_servers | awk '{print $1}'`
sed -i ''"$BB"'c  pm.max_spare_servers = 20'  /usr/local/php/etc/php-fpm.conf
CC=`cat -vn /usr/local/php/etc/php-fpm.conf | grep min_spare_servers | awk '{print $1}'`
sed -i ''"$CC"'c  pm.min_spare_servers = 10'  /usr/local/php/etc/php-fpm.conf
DD=`cat -vn /usr/local/php/etc/php-fpm.conf | grep start_servers | awk '{print $1}'`
sed -i ''"$DD"'c  pm.start_servers = 15'  /usr/local/php/etc/php-fpm.conf


sed -i '19a pm.max_requests = 10240'  /usr/local/php/etc/php-fpm.conf
PINI=`cat -n /usr/local/php/etc/php-fpm.conf | grep backlog  | awk '{print $1}'`
sed -i ''"$PINI"'c  listen.backlog = 500'   /usr/local/php/etc/php-fpm.conf


#隐藏版本号
PHPBB=`cat -n  /usr/local/php/etc/php.ini   | grep expose_php | awk '{print $1}'`
sed -i ''"$PHPBB"'c  expose_php=Off'   /usr/local/php/etc/php.ini
